<template>
	<view class="content">
		<!-- 搜索 -->
		<searchLink></searchLink>
		<!-- 轮播图 -->
		<swiper class="swiper" circular autoplay indicator-dots indicator-active-color="#fff" indicator-color="rgba(255,255,255,.5)">
			<swiper-item v-for="(item,index) in swiperList" :key="index">
				<image :src="item.image_src" mode=""></image>
			</swiper-item>
		</swiper>
		<!-- 导航 -->
		<view class="nav">
			<image :src="item.image_src" mode="" v-for="(item,index) in catitemList" :key="index"></image>
		</view>
		<!-- 商品楼层 -->
		<view class="floor">
			<view class="floor-item" v-for="(floorItem,floorIndex) in floorList" :key="floorIndex">
				<image :src="floorItem.floor_title.image_src" mode=""></image>
				<view class="floor-the-container">
					<image :src="floorItem.product_list[0].image_src" mode=""></image>
					<view class="right">
						<image :src="item.image_src" mode="" v-for="(item,index) in floorItem.product_list.slice(1)" :key="index"></image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import searchLink from '@/components/search-link/search-link.vue'
	export default {
		components: {
			searchLink
		},
		data() {
			return {
				swiperList: [],
				catitemList: [],
				floorList: []
			}
		},
		onLoad() {
			this.getSwiperdata()
			this.getCatitems()
			this.getFloordata()
		},
		// 检测用户下拉
		onPullDownRefresh(){
			uni.stopPullDownRefresh()
		},
		methods: {
			// 轮播图
			async getSwiperdata() {
				this.swiperList = await this.$request({
					url: '/api/public/v1/home/swiperdata'
				})
			},
			// 导航栏
			async getCatitems() {
				this.catitemList = await this.$request({
					url: '/api/public/v1/home/catitems'
				})

			},
			// 商品楼
			async getFloordata() {
				this.floorList = await this.$request({
					url: '/api/public/v1/home/floordata'
				})
			}

		},

	}
</script>

<style lang="less">
	.content {

		// 搜索框
		.search-link {
			background-color: #ed4450;
			padding: 20rpx 16rpx;

			.search-box {
				height: 60rpx;
				background-color: #fff;
				display: flex;
				align-items: center;
				justify-content: center;
				border-radius: 8rpx;
				color: #bbb;

				icon {
					margin-top: 4rpx;
				}

				text {
					margin-left: 10rpx;
				}
			}
		}

		// 轮播图
		.swiper {
			height: 340rpx;

			image {
				width: 100%;
				height: 340rpx;
			}
		}

		// 导航
		.nav {
			display: flex;
			height: 194rpx;
			justify-content: space-evenly;
			align-items: center;
			background-color: #fff;

			image {
				width: 128rpx;
				height: 140rpx;
			}
		}

		// 商品楼层

		.floor {
			.floor-item {
				>image {
					width: 100%;
					height: 58rpx;
					// background-color: #f4f4f4;
					padding-top: 30rpx;
				}

				.floor-the-container {
					margin: 10rpx 0 40rpx;
					padding: 0 17rpx;
					display: flex;

					>image {
						width: 232rpx;
						height: 386rpx;
					}

					.right {
						flex: 1;
						display: flex;
						flex-wrap: wrap;
						margin-left: 10rpx;
						justify-content: space-between;
						align-content: space-between;

						image {
							width: 232rpx;
							height: 188rpx;
						}
					}
				}
			}
		}
	}
</style>
